package com.itany.corejava.code07_常用类.日期类;

import com.itany.corejava.util.DateUtil;

import java.text.ParseException;
import java.util.Date;

/**
 * @author MissChen
 * @date 2024年03月01日 16:31
 */
public class Test04_工具类 {
    public static void main(String[] args) throws ParseException {
        Date today=new Date();
        String str=DateUtil.dateToString(today,"yyyy-MM-dd HH:mm:ss");
        System.out.println(str);
        String str2=DateUtil.dateToString(today,"yyyy年MM月dd日 HH:mm:ss");
        System.out.println(str2);

        String str3=DateUtil.dateToString(today);
        System.out.println(str3);

        String str4="2024/03/08 12:23:19";
        Date d1=DateUtil.stringToDate(str4,"yyyy/MM/dd HH:mm:ss");
        System.out.println(d1);
        String str5="2024-03-08 12:23:19";
        Date d2=DateUtil.stringToDate(str5);
        System.out.println(d2);

        Date d3=DateUtil.getYesterday(new Date());
        System.out.println(d3);
        Date d4=DateUtil.getNextDay(new Date());
        System.out.println(d4);

        //计算昨天和明天之间的天数
        int days=DateUtil.getDuringDay(d3,d4);
        System.out.println(days);

        int m=DateUtil.get(new Date(),4);
        System.out.println(m);
    }
}
